package com.shujia.flink.transformation

import org.apache.flink.streaming.api.scala._
import org.apache.flink.streaming.api.windowing.time.Time

object Demo6Window {
  def main(args: Array[String]): Unit = {
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment


    val ds: DataStream[String] = env.socketTextStream("master", 9999)


    ds.map((_, 1))
      .keyBy(_._1)
      .timeWindow(Time.seconds(5)) //滚动窗口
      .sum(1)
      .print()


    env.execute()


  }
}
